package com.witframework.core.message;


import com.witframework.util.IdGenerator;

public class UIMessage {
	//提示信息
	public static int INFO=1;
	//警告信息
	public static int WARNING=2;
	//错误信息
	public static int ERROR=3;

	public static int POP=0;
	private static int MAXMSGLENGTH=256;
	private int type;
	private String msg;
	private String id;
	private long creatTime;
	public UIMessage(String msgText,int msgType){
		if(msgText==null){
			id=null;
		}else{
			id=IdGenerator.generateId(msgText);
			creatTime=System.currentTimeMillis();
			type=msgType;
			if(msgText.length()>MAXMSGLENGTH)
				msg=msgText.substring(0,MAXMSGLENGTH);
			else
				msg=msgText;
		}
	}

	public String getMsg() {
		return msg;
	}
	public String getId() {
		return id;
	}
	public long getCreatTime() {
		return creatTime;
	}
	public int compareTo(UIMessage o){
		return (int)(creatTime-o.getCreatTime());
	}
	public int getType() {
		return type;
	}
	public String[] readMessage(String requestid){
		return MessageCacheManager.getInstance().getText(requestid);
	}
}
